//
//  HistoryDetailVC.m
//  MyDemo
//
//  Created by jay on 2020/8/23.
//  Copyright © 2020 jay. All rights reserved.
//

#import "HistoryDetailVC.h"
#import "HistoryDetailVM.h"
#import "MainCell.h"

@interface HistoryDetailVC ()

@property (nonatomic, strong) HistoryDetailVM *curVM;

@end

@implementation HistoryDetailVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationItem.title = @"记录详情";
    
    self.myTableView.backgroundColor = TX_COLOR_FROM_RGB(0xFAFAFA);
    self.myTableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
    [self.myTableView registerClass:[MainCell class] forCellReuseIdentifier:kTableCellID];
}

#pragma mark - UITableViewDataSource & UITableViewDelegate

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return [self.curVM rowNumber];
}

- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return UITableViewAutomaticDimension;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    MainCell *cell = [tableView dequeueReusableCellWithIdentifier:kTableCellID];
    
    cell.titleLabel.text = [self.curVM propertyNameForRow:indexPath.row];
    
    cell.contentLabel.text = [self.curVM propertyValueForRow:indexPath.row];

    return cell;
}

#pragma mark - Getter

- (HistoryDetailVM *)curVM {
    if(_curVM == nil) {
        _curVM = [[HistoryDetailVM alloc] init];
        
        _curVM.curModel = self.curModel;
    }
    return _curVM;
}

@end
